function fixdata(data) {
    var arr = [];
    for (var i in data) {
        arr.push(i + '=' + data[i])
    }
    return arr.join('&');
}
function myajax(options) {
    var xhr = new XMLHttpRequest();
    if (options.method.toUpperCase() === 'GET') {
        xhr.open(options.method, options.url + '?' + fixdata(options.data));
        xhr.send();
    } else if (options.method.toUpperCase() === 'POST') {
        xhr.open(options.method, options.url);
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.send(fixdata(options.data));
    }
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
            if (xhr.status >= 200 && xhr.status < 300) {
                var res = JSON.parse(xhr.responseText);
                options.success(res);
            }
            // console.log(xhr.responseText);
        }
    }
}